
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class UmsUserServiceImpl implements UmsUserService  {

    @Resource
    private UmsUserMapper umsUserMapper;

    /**
     * 获取 UmsUser 分页列表
     */
    @Transactional
    public IPage getUmsUserPagination( PaginationVo paginationVo, UmsUserQuery umsUserQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<UmsUserEntity> lqs = new LambdaQueryWrapper();
        umsUserMapper.selectPage(page, lqs);

        List<UmsUserEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 UmsUser 所有数据
     *
    */
    @Transactional
    public List<UmsUserEntity> getUmsUserAllList( UmsUserQuery umsUserQuery ) throws Exception {

        LambdaQueryWrapper<UmsUserEntity> lqs = new LambdaQueryWrapper();
        List<UmsUserEntity> list = umsUserMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 UmsUser 详情
    */
    @Transactional
    public UmsUserEntity getUmsUserDetail( Long id) throws Exception {

        UmsUserEntity umsUser = umsUserMapper.selectById(id);
        return umsUser;
    }


    /**
     * 新增 UmsUser
     * */
    @Transactional
    public void addUmsUser(UmsUserVo umsUserVo) throws Exception {

        UmsUserEntity umsUser = new UmsUserEntity();
        ReflectionCopy.copyProperties( umsUser, umsUserVo );
        umsUserMapper.insert(umsUser);
        return;
    }


    /**
     * 更新 UmsUser
     * */
    @Transactional
    public void updateUmsUser( UmsUserVo umsUserVo) throws Exception {

        if( umsUserVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        UmsUserEntity umsUser = new UmsUserEntity();
        ReflectionCopy.copyProperties( umsUser, umsUserVo );
        umsUserMapper.updateById(umsUser);
        return;
    }

    /**
     * 删除 UmsUser
     * */
    @Transactional
    public void batchRemoveUmsUser( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        umsUserMapper.deleteBatchIds(ids);
    }

}

      